import JL_Router from "../router";


JL_Router.beforeEach((to, from, next) => {
  let sessionId = localStorage.getItem("SessionId");
  let default_page = localStorage.getItem("default_page") || 'agent';
  if (to.name != 'login' && $Utils.isNull(sessionId)) {
    next({name: 'login'})
  } else if ((to.name == 'index' || to.name == 'login') && !$Utils.isNull(default_page) && !$Utils.isNull(sessionId)) {
    next({name: default_page})
  } else if (to.name == 'index' && $Utils.isNull(default_page) && $Utils.isNull(sessionId)) {
    next({name: 'login'})
  } else {
    next()
  }
});
